<form action="?act=10" name="frmxlEditCH" method="post">
<table width="100%" class="XuLy" >
<?php
	include("../lib/DataProvider.php");
	if(isset($_GET['sk']))
	{
		$sk=$_GET['sk'];
		switch ($sk)
		{
			case 1:
				?>
				<tr>
					<td colspan="2" class="center">Thêm Cấu hình(cấu hình chung) </td>
				</tr>
				<tr>
					<td class="canphai">Tên cấu hình:</td>
					<td><input name="txtTenCH" type="text" id="txtTenCH" size="30"></td>
				</tr>
				<tr>
					<td class="canphai">Mã LSP:</td>
					<td><input name="txtMaLSP" type="text" id="txtMaLSP" size="30"></td>
				</tr>
				<tr>
					<td></td>
					<td >
						<input type="submit" name="btnThem" id="btnThem" value="Thêm">
						<input type="reset" name="btnReset" value="Làm mới">
						<input type="button" name="btnHuy" value="Huỷ bỏ" onclick="HuyEditCH()">
					</td>
				</tr>
				<?php
				break;
			case 2:
				if(isset($_GET['ID']))
				{
					$MaCH=$_GET['ID'];
					$ds=DataProvider::ExecuteQuery("select * from cauhinh where MACH='".$MaCH."'");
					?>
					<tr>
						<td colspan="2" class="center">Sửa cấu hình</td>
					</tr>
					<?php
					while($row = mysql_fetch_array($ds,MYSQL_ASSOC))
					{?>
						<tr>
						<td class="canphai">Mã cấu hình:</td>
						<td><?php echo $MaCH;?></td>
						<input type="hidden" name="txtMaCH" id="txtMaCH" value="<?php echo $MaCH;?>">
						</tr>
						<tr>
							<td class="canphai">Tên cấu hình:</td>
							<td><input type="text" name="txtTenCH" id="txtTenCH" value="<?php echo $row['TENCH'];?>"></td>
						</tr>
						<tr>
							<td class="canphai">Mã LSP:</td>
							<td><input type="text" name="txtMaLSP" id="txtMaLSP" value="<?php echo $row['MALSP'];?>"></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="checkbox" name="cbBiXoa" id="cbBiXoa" <?php if($row['BIXOA']==1) echo "checked='checked'";?>>
							Bị xoá</td>
						</tr>
						<tr>
							<td></td>
							<td><input type="submit" name="btnCapNhat" id="btnCapNhat" value="Cập nhật" />
								<input type="reset" name="btnReset" id="btnReset" value="Làm mới" />
								<input type="button" name="btnHuy" id="btnHuy" value="Huỷ" onclick="HuyEditCH()"/>
							</td>
						</tr>
					<?php }
				}					
				break;
			case 3:
				if(isset($_GET['ID']))
				{
					$MaCH=$_GET['ID'];
					$ds=DataProvider::ExecuteQuery("select * from cauhinhsanpham where MACH='".$MaCH."'");
					if(mysql_num_rows($ds)>0)
					{
						$update=DataProvider::ExecuteQuery("update cauhinh set BIXOA=1 where MACH='".$MaCH."'");
						echo '<div class="center"><b>Cấu hình này đã được sử dụng! Chúng ta sẽ dánh dấu xoá.</b></div>';
					?>
						<head>
						<meta http-equiv="refresh" content="2; url=?act=4" />
						</head>
					<?php
					}else{
						$delete=DataProvider::ExecuteQuery("delete from cauhinh where MACH='".$MaCH."'");
						echo '<div class="center"><b>Xoá thành công!</b></div>';
						?>
							<head>
							<meta http-equiv="refresh" content="2; url=?act=4" />
							</head>
						<?php
					}
				}
				break;
		}
	}
?>